"""
@name : 7.13作业
@author : tnn
@projectname: 天龙八部
"""
#练习：
#lst = ['a','1','2bb','234','','9']
#使用reduce   取出lst里的数字  --》    12349
from functools import reduce
lst = ['a','1','2bb','234','','9']
lst2 = list(filter( lambda x: x.isdigit() ,lst))
print(lst2)
print(reduce(lambda x,y:x+y, lst2))


# 2、有以下列表:list1 = [7, -8, 5, 4, 0, -2, -5]
# 要求:1.正数在前，负数在后  2.正数从小到大  3.负数从大到小
res = [7,-8,5,4,0,-2,-5]

def func():
    r1 = []
    r2 = []
    for i in res:
        if i >=0:
            r1.append(i)
        else:
            r2.append(i)
    return sorted(r1,reverse = False)+sorted(r2,reverse = True)
print(func())

# # 3、这是一个字符串排序，排序规则:小写<大写<奇数<偶数
str1 = 'asdf234GDSdsf23'

def num_sort(num):
    if num.isdigit():
        if int(num) % 2 == 1:
            return (ord(num)+100)*-1
        else:
            return (ord(num)+200)*-1
    return ord(num)
print(''.join(sorted(str1,key=num_sort,reverse=True)))





